package com.tiny.mirror.service.product.interfaces.maintain;

import com.google.common.collect.Lists;
import com.tiny.mirror.service.product.domain.ability.AbilityParams;
import com.tiny.mirror.service.product.domain.ability.LhcParams;
import com.tiny.mirror.service.product.domain.ability.LhcParams.LhcPlayParams;
import com.tiny.mirror.service.product.enums.AbilityLhcTypeEnum;
import com.tiny.mirror.service.product.infrastructure.entity.db.AbilityEntity;
import com.tiny.mirror.service.product.infrastructure.repository.db.AbilityMapper;
import com.tiny.mirror.service.product.support.strategy.lhc.LhcStrategy;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: liujsh
 * @Description:
 * @Date: Create in 2023/10/26
 */
@RestController
@RequestMapping("/maintain")
public class MaintainController {

  @Resource
  private List<LhcStrategy> lhcStrategyList;
  @Resource
  private AbilityMapper abilityMapper;

  @GetMapping(value = "/init")
  public void init() {
    AbilityEntity abilityEntity = abilityMapper.selectById(1L);
    AbilityParams abilityParams = new AbilityParams();
    {
      LhcParams lhcParams = new LhcParams();
      lhcParams.setRule("xgc-规则");
      lhcParams.setType(AbilityLhcTypeEnum.XGC);
      List<LhcPlayParams> list = Lists.newArrayList();
      for (LhcStrategy lhcStrategy : lhcStrategyList) {
        list.add(lhcStrategy.build());
      }
      lhcParams.setPlayList(list);
      abilityParams.setLhcParams(lhcParams);
    }
    abilityEntity.setParams(abilityParams);
    abilityMapper.updateById(abilityEntity);
  }
}
